package com.example.ai.embedding;

import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.vectorstore.SimpleVectorStore;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.io.File;

//@Component
public class SimpleVectorStoreConfiguration {
    @Value("${vector.db.path}")
    private String vectorDbPath;
    @Bean
    public VectorStore vectorStore(EmbeddingModel embeddingModel){
        return SimpleVectorStore.builder(embeddingModel).build();
    }
    @Bean
    CommandLineRunner commandLineRunner(VectorStore vectorStore) {
        return args -> {
            ((SimpleVectorStore)vectorStore).load(new File(vectorDbPath));
        };
    }

}
